<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客服管理')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>卡密:</label>
                            <input type="text" name="kamicode"/>
                        </li>
                        <li>
                            卡密状态：<select name="actStatus">
                            <option value="">所有</option>
                            <option value="0">未激活</option>
                            <option value="1">已激活</option>
                        </select>
                        <li>
                            是否到期：<select name="isEnd">
                            <option value="">所有</option>
                            <option value="0">已过期</option>
                            <option value="1">未过期</option>
                        </select>

                        </li>




                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="btn-group-sm" id="toolbar" role="group">
             <a class="btn btn-success" onclick="add()" shiro:hasPermission="im:users:add">
                <i class="fa fa-plus"></i> 添加
             </a>
<!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="im:users:edit">-->
<!--                <i class="fa fa-edit"></i> 修改-->
<!--            </a>-->
<!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="im:users:remove">-->
<!--                <i class="fa fa-remove"></i> 删除-->
<!--            </a>-->
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="im:users:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('im:users:edit')}]];
    var removeFlag = [[${@permission.hasPermi('im:users:remove')}]];
    var statusDatas = [[${@dict.getType('im_stauts')}]];
    var kf_type_Datas = [[${@dict.getType('user_kf_type')}]];
    var actStatus = [[${@dict.getType('user_act_status')}]];
    var prefix = ctx + "im/server";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "客服管理",
            columns: [
                {
                    checkbox: true
                }, {
                    field: 'faceUrl',
                    title: '头像',
                    formatter: function(value, row, index) {
                        var img = "";
                        if (value){
                            img = '<img style="width: 40px;height: 40px;border-radius: 5px;" src="'+value+'"/>';
                        } else {
                            img = '<img style="width: 40px;height: 40px;border-radius: 5px;" src="/img/profile.jpg"/>';
                        }
                        return img;
                    }
                },{
                    field: 'kamicode',
                    title: '卡密账号'
                }, {
                    field: 'name',
                    title: '昵称'
                }, {
                    field: 'createTime',
                    title: '添加时间'
                },
                {
                    field: 'actStatus',
                    title: '账号状态',
                      formatter: function(value, row, index) {
                       return $.table.selectDictLabel(actStatus, value);
                    }
                },
                {
                    field: 'endTime',
                    title: '到期时间'
                },
                 {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="myGroup(\'' + row.userId + '\')"><i class="fa fa-edit"></i>群聊列表</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>修改信息</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="xufei(\'' + row.userId + '\')"><i class="fa fa-edit"></i>续费</a> ');
                        <!--actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');-->
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /* 用户状态显示 */
    function statusTools(row) {
        if (row.status == 0) {
            return '<i class=\"fa fa-toggle-off text-danger fa-2x\" onclick="enable(\'' + row.userId + '\')" ></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
        }
    }

    /* 用户管理-停用 */
    function disable(userId) {
        $.modal.confirm("确认要停用用户吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
        })
    }

    /* 用户管理启用 */
    function enable(userId) {
        $.modal.confirm("确认要启用用户吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 1 });
        })
    }

    /* 用户管理-重置密码 */
		function resetPwd(userId) {
		    var url = prefix + '/resetPwd/' + userId;
		    $.modal.confirm("确认重置为123456吗?",function(){
		      $.operate.post(prefix + "/resetPwd", { "userId": userId, "status": 0 });
		    });
		}
	/* 用户管理-群聊列表 */
		function myGroup(userId) {
		    var url = '/im/groups?creatorUserId=' + userId;
            $.modal.openTab("群聊列表", url);
		}
		<!---->
		function xufei(userId) {
		    var url = prefix + '/xufei/' + userId;
		    $.modal.open("续费", url);
		}

		function add() {
		    var url = prefix + '/add';
		    $.modal.open("开户", url);
		}
</script>
</body>
</html>
